wasi: relax WebAssembly.Instance type check#33431
Closed
bnoordhuis wants to merge 1 commit intonodejs:masterfrom
Closed
wasi: relax WebAssembly.Instance type check#33431bnoordhuis wants to merge 1 commit intonodejs:masterfrom
bnoordhuis wants to merge 1 commit intonodejs:masterfrom
Conversation
Instances coming from different VM contexts don't pass `instanceof` type checks because each context has its own copy of the built-in globals. After review of the relevant code it seems like it should be safe to relax the type check and that is what this commit does: `wasi.start()` now accepts any input that walks and quacks like a WebAssembly.Instance or WebAssembly.Memory instance. Fixes: nodejs#33415
addaleax
approved these changes
May 16, 2020
benjamingr
approved these changes
May 16, 2020
cjihrig
approved these changes
May 16, 2020
Collaborator
jasnell
reviewed
May 18, 2020
| // an ArrayBuffer. Long story short, we don't need much validation here | ||
| // but we type-check anyway because it helps catch bugs in the user's | ||
| // code early. | ||
| validateObject(memory, 'instance.exports.memory'); |
Member
There was a problem hiding this comment.
non-blocking observation: one additional check we could do here is to check that memory.constructor.name === 'Memory'.
Member
There was a problem hiding this comment.
I don’t see why anybody would ever subclass WebAssembly.Memory, but then again I don’t really see why we would ever want to forbid that. I think this can stay as-is.
jasnell
approved these changes
May 18, 2020
Collaborator
Collaborator
BridgeAR
approved these changes
May 23, 2020
BridgeAR
pushed a commit
to BridgeAR/node
that referenced
this pull request
May 23, 2020
Instances coming from different VM contexts don't pass `instanceof` type checks because each context has its own copy of the built-in globals. After review of the relevant code it seems like it should be safe to relax the type check and that is what this commit does: `wasi.start()` now accepts any input that walks and quacks like a WebAssembly.Instance or WebAssembly.Memory instance. Fixes: nodejs#33415 PR-URL: nodejs#33431 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Member
|
Landed in 9ad8b4d 🎉 |
codebytere
pushed a commit
that referenced
this pull request
Jun 18, 2020
Instances coming from different VM contexts don't pass `instanceof` type checks because each context has its own copy of the built-in globals. After review of the relevant code it seems like it should be safe to relax the type check and that is what this commit does: `wasi.start()` now accepts any input that walks and quacks like a WebAssembly.Instance or WebAssembly.Memory instance. Fixes: #33415 PR-URL: #33431 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
codebytere
pushed a commit
that referenced
this pull request
Jun 18, 2020
Instances coming from different VM contexts don't pass `instanceof` type checks because each context has its own copy of the built-in globals. After review of the relevant code it seems like it should be safe to relax the type check and that is what this commit does: `wasi.start()` now accepts any input that walks and quacks like a WebAssembly.Instance or WebAssembly.Memory instance. Fixes: #33415 PR-URL: #33431 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Merged
codebytere
pushed a commit
that referenced
this pull request
Jun 30, 2020
Instances coming from different VM contexts don't pass `instanceof` type checks because each context has its own copy of the built-in globals. After review of the relevant code it seems like it should be safe to relax the type check and that is what this commit does: `wasi.start()` now accepts any input that walks and quacks like a WebAssembly.Instance or WebAssembly.Memory instance. Fixes: #33415 PR-URL: #33431 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
codebytere
pushed a commit
that referenced
this pull request
Jul 8, 2020
Instances coming from different VM contexts don't pass `instanceof` type checks because each context has its own copy of the built-in globals. After review of the relevant code it seems like it should be safe to relax the type check and that is what this commit does: `wasi.start()` now accepts any input that walks and quacks like a WebAssembly.Instance or WebAssembly.Memory instance. Fixes: #33415 PR-URL: #33431 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Instances coming from different VM contexts don't pass
instanceoftype checks because each context has its own copy of the built-in
globals.
After review of the relevant code it seems like it should be safe to
relax the type check and that is what this commit does:
wasi.start()now accepts any input that walks and quacks like a WebAssembly.Instance
or WebAssembly.Memory instance.
Fixes: #33415